package com.zh.common.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by lds
 * 2019-04-1
 * 枚举方式统一管理错误编码
 */
public enum ResultEnum {
    SUCCESS(0, "成功"),
    FAILURE(1, "失败"),
    ILLEGAL_ERROR(-100,"非法请求"),
    NO_DATA_ERROR(300, "没有数据"),
    GOODS_DOWN_ERROR(301, "商品已下架"),
    NO_ORDER_ERROR(302, "订单不存在"),
    NO_DOC_ERROR(303, "该文章已删除"),
    NO_EVALUTION_ERROR(303, "回复的评价不存在"),
    NO_FINISH_ORDER_ERROR(304, "订单未完成，不能评价"),
    NO_USERNAME_ERROR(305,"请输入手机号码"),
    NO_PASSWORD_ERROR(306,"请输入密码"),
    NO_USER_ERROR(307,"该用户不存在"),
    FORBIDDEN_USER_ERROR(308,"该用户被禁用"),
    USER_DEL_ERROR(309,"该用户被移除"),
    USER_PASSWORD_ERROR(310,"密码错误"),
    NO_SERVICE_ERROR(311,"该服务已不存在"),
    FORBIDDEN_SERVICE_ERROR(312,"该服务被禁用"),
    NO_SITE_ERROR(313,"该收货地址已不存在"),
    NO_VERIFY_ERROR(314,"该服务审核未完成"),
    NO_GOODS_ERROR(315,"该商品已不存在"),
    USER_NO_VERIFY_ERROR(316,"该用户未完成审核"),
    NO_PHONE_ERROR(317,"手机号码不能为空"),
    NO_CODE_ERROR(318,"短信验证码失效，请重新发送"),
    CODE_ERROR(313,"短信验证码不正确，请重新输入"),
    PARAME_ERROR(400, "参数错误"),
    SERVER_ERROR(500, "服务繁忙"),
    NO_OLDMAN(320,"该老人不存在"),
    TOKEN_INVALID_ERROR(505, "身份过期，请重新登录"),
    UNAUTHENTIC(100401, "无权访问，当前是匿名访问，请先登录！"),
    UNAUTHORIZED(100403, "无权访问，当前帐号权限不足！"),
    NOTFOUND(100404, "服务器未找到资源"),
    ;
    private Integer code;

    private String msg;

    ResultEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Map<String, Object> result() {
        Map result = new HashMap<String, Object>(3);
        result.put("code", this.code);
        result.put("msg", this.msg);
        return result;
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }
}
